package com.kxf.utils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @ProjectName: AndroidTestDemo
 * @Package: com.kxf.androidtestdemo.utils
 * @ClassName: MaxSizeHashMap
 * @Description: 固定长度的map
 * @Author: kuangxuefeng
 * @qq: 1024883177
 * @CreateDate: 2020/6/16 17:13
 */
public class MaxSizeHashMap<K, V> extends LinkedHashMap<K, V> {
    private final int maxSize;

    public MaxSizeHashMap(int maxSize) {
        this.maxSize = maxSize;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
        return size() > maxSize;
    }
}
